<template>
  <div>
    <el-container>
      <el-header>
        <el-menu
          :default-active="activeIndex2"
          class="el-menu-demo"
          mode="horizontal"
          @select="handleSelect"
          background-color="#5a5a2d"
          text-color="#fff"
          active-text-color="#ffd04b">
          <el-menu-item index="1">
            <router-link to="/" tag="span" class="logo"><img src="../../assets/woniuxueyuan.png" alt=""></router-link>
          </el-menu-item>
          <el-submenu index="2">
            <template slot="title">
              <router-link to="/student/studentcourse" tag="span" style="">我的课程</router-link>
            </template>
            <el-submenu index="2-1">
              <template slot="title">
                <router-link to="/student/studentcourse/studentcoursecourse" tag="span">我的课程</router-link>
              </template>
              <el-menu-item index="2-1-1">
                <router-link to="/student/studentcourse/studentcoursecourse/studentcoursecourseall" tag="span">全部</router-link>
              </el-menu-item>
              <el-menu-item index="2-1-2">
                <router-link to="/student/studentcourse/studentcoursecourse/studentcoursecoursestart" tag="span">即将开始</router-link>
              </el-menu-item>
              <el-menu-item index="2-1-3">
                <router-link to="/student/studentcourse/studentcoursecourse/studentcoursecourseing" tag="span">进行中</router-link>
              </el-menu-item>
              <el-menu-item index="2-1-4">
                <router-link to="/student/studentcourse/studentcoursecourse/studentcoursecourseend" tag="span">已结束</router-link>
              </el-menu-item>
            </el-submenu>
            <el-menu-item index="2-2">
              <router-link to="/student/studentcourse/studentcoursecollection" tag="span">我的收藏</router-link>
            </el-menu-item>
            <el-submenu index="2-3">
              <template slot="title">
                <router-link to="/student/studentcourse/studentcoursetest" tag="span">考试练习</router-link>
              </template>
              <el-menu-item index="2-3-1">
                <router-link to="/student/studentcourse/studentcoursetest/studentcoursetestchapter" tag="span">章节练习</router-link>
              </el-menu-item>
              <el-menu-item index="2-3-2">
                <router-link to="/student/studentcourse/studentcoursetest/studentcoursetestfinal" tag="span">期末测试</router-link>
              </el-menu-item>
              <el-menu-item index="2-3-3">
                <router-link to="/student/studentcourse/studentcoursetest/studentcoursetestdiscussion" tag="span">课内讨论</router-link>
              </el-menu-item>
            </el-submenu>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title">
              <router-link to="/student/studentorder" tag="span">购买记录</router-link>
            </template>
            <el-menu-item index="3-1">
              <router-link to="/student/studentorder/studentorderbuy" tag="span">购买记录</router-link>
            </el-menu-item>
            <el-menu-item index="3-2">
              <router-link to="/student/studentorder/studentorderrefund" tag="span">退款订单</router-link>
            </el-menu-item>
          </el-submenu>
          <el-submenu index="4">
            <template slot="title">
              <router-link to="/student/studentsetup" tag="span">设置</router-link>
            </template>
            <el-submenu index="4-1">
              <template slot="title">
                <router-link to="/student/studentsetup/studentsetupinfo" tag="span">资料设置</router-link>
              </template>
              <el-menu-item index="4-1-1">
                <router-link to="/student/studentsetup/studentsetupinfo/studentsetupinfostudent" tag="span">个人信息设置</router-link>
              </el-menu-item>
              <el-menu-item index="4-1-2">
                <router-link to="/student/studentsetup/studentsetupinfo/studentsetupinfouser" tag="span">账户信息设置</router-link>
              </el-menu-item>
            </el-submenu>
            <el-menu-item index="4-2">
              <router-link to="/student/studentsetup/studentsetupmessage" tag="span">消息设置</router-link>
            </el-menu-item>
            <el-menu-item index="4-3">
              <router-link to="/student/studentsetup/studentsetupprivacy" tag="span">隐私设置</router-link>
            </el-menu-item>
            <el-menu-item index="4-4">
              <router-link to="/student/studentsetup/studentsetuppay" tag="span">支付设置</router-link>
            </el-menu-item>
          </el-submenu>
          <el-menu-item index="5" style="margin-left: 400px">
            <router-link to="/student/studentmessage" tag="span">
              <span><font-awesome-icon :icon="['far', 'bell']"></font-awesome-icon></span>
            </router-link>
          </el-menu-item>
          <el-menu-item index="6">
            <router-link to="/student/studentcourse/studentcoursecourse" tag="span">
              <span style="color: white">欢迎您,</span>
              <span style="color: red">{{student.nickname}}!</span>
              <span class="uimg"><img :src="student.image" alt=""></span>
            </router-link>
          </el-menu-item>
        </el-menu>
      </el-header>
      <el-main><router-view></router-view></el-main>
    </el-container>
  </div>
</template>

<script>

export default {
  name: "student",
  data(){
    return{
      student: {},
      user: {},
      activeIndex: '1',
      activeIndex2: '1',

    }
  },

  beforeCreate() {
    this.axios.post(this.baseUrl+"student/add")
      .then(res =>{
        console.log(res.data)
      });
  },
  created() {
    //发送请求获取数据
    this.axios.get(this.baseUrl + "student/all")
      .then(res => {
        //res.data   ResponseResult
        console.log(res.data);
        //
        this.student = res.data.data;
        this.$store.commit('setStudent', this.student);
      });
    this.user = this.$store.state.grades;
  },
  methods: {
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
    }
  }
}
</script>

<style scoped>
  @import "../../assets/css/student.css";
</style>
